package com.ly.im.controller;

import cn.hutool.core.util.StrUtil;
import com.ly.im.pojo.vo.LoginUserVo;
import com.ly.im.service.LoginService;
import com.ly.im.utils.ResponseUtils;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @Author LY
 * @create 2024/2/2 11:13
 * @Description login
 */
@RestController
@RequestMapping("/login")
public class LoginController {

    @Resource
    private LoginService loginService;

    @PostMapping
    public Object login(@RequestBody LoginUserVo vo){
        if (StrUtil.isEmpty(vo.getUsername()) || StrUtil.isEmpty(vo.getPassword())){
            return ResponseUtils.badArgument();
        }
        return loginService.login(vo.getUsername(), vo.getPassword());
    }
}
